#include "dialog.h"
#include "ui_dialog.h"
#include<QPainter>
#include <QPushButton>
Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
    cse=false;
    ui->buttonBox->button(QDialogButtonBox::Ok)->setText("确定");//将buttonbox中的ok 变成汉化
    ui->buttonBox->button(QDialogButtonBox::Cancel)->setText("取消");
}
Dialog::Dialog(QString &ip,QString  &build,QString  &unit,QString  &room,QString &admin,QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
    ui->lineEdit->setText(build);
    ui->lineEdit_2->setText(unit);
    ui->lineEdit_3->setText(room);
    ui->lineEdit_4->setText(admin);
    ui->lineEdit_5->setText(ip);
    cse=true;
    ui->buttonBox->button(QDialogButtonBox::Ok)->setText("确定");//将buttonbox中的ok 变成汉化
    ui->buttonBox->button(QDialogButtonBox::Cancel)->setText("取消");
}
void Dialog::paintEvent(QPaintEvent *)//背景
{
//   QPixmap pix("images/test.jpg");
//   QPainter painter(this);
//   int w = width();
//   int h = height();
//   painter.drawPixmap(0,0,w,h,pix);
    // QPixmap pix("images/test.jpg");
        QPainter painter(this);
    //151 255 255
        painter.setBrush(QColor(240,255,255));

        int w = width();
        int h = height();

        painter.drawRect(0,0,w,h);
      //  painter.drawPixmap(0,0,w,h,pix);
}
Dialog::~Dialog()
{
    delete ui;
}
void Dialog::on_buttonBox_accepted()
{
    QString build,unit,room,admin,ip;
    build=ui->lineEdit->text();
    unit=ui->lineEdit_2->text();
    room=ui->lineEdit_3->text();
    admin=ui->lineEdit_4->text();
    if((ip=ui->lineEdit_5->text()).isEmpty())
        return;
    Mydata mydata(build,unit,room,admin,ip,cse);
    emit sendMassge(mydata);
}
